package com.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.user.common.R;
import com.user.entity.ResultResponse;
import com.user.vo.UserVo;
import com.usian.model.shop.User;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 登录 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-12-17
 */
public interface UserMapper extends BaseMapper<User> {

    List<User> findList(@Param("user") User user);

    @Update("update user set pay_password = #{code} where id = #{uid}")
    int setPayPassword(@Param("uid") Integer uid, @Param("code") Integer code);

    @Select("select pay_password from user where id = #{id}")
    String getPayPassword(Integer id);

    @Update("UPDATE user SET name = #{name} WHERE id = #{id}")
    void updateUserById(@Param("name") String name, @Param("id") Integer id);

    @Select("SELECT score FROM user WHERE id = #{id}")
    Integer findScoreId(Integer id);

    @Update("UPDATE user SET score = #{score} WHERE id = #{id}")
    int updateScore(@Param("id") Integer id, @Param("score") Integer score);

    @Update("UPDATE user SET birth = #{birth} WHERE id = #{id}")
    void updateBirthById(@Param("birth") Date birth,@Param("id")  Integer id);

    @Select("SELECT sign_time FROM user WHERE id = #{id}")
    Date signIn(Integer id);

    @Update("UPDATE user SET sign_time = #{date1} WHERE id = #{id}")
    void updateSignTime(@Param("date1") Date date1,@Param("id") Integer id);


    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteUser(@Param("id") Integer id);


    @Update("UPDATE user SET image = #{image} WHERE id = #{id}")
    boolean updateImage(@Param("id") Integer id, @Param("image") String image);


    @Update("UPDATE user SET password = #{password} WHERE phone = #{phone}")
    void updatePassword(@Param("phone") String phone,@Param("password") String password);

}
